package ui.tools;

import java.awt.Point;

import board.SimpleMark;

import ui.EditController;

/**
 * EditTool for adding SimpleMarks.
 * @author TKington
 *
 */
public class MarkTool extends EditTool {
	/** Mark type to add. */
	private int type;
	
	/**
	 * Creates a MarkTool
	 * @param type the mark type
	 */
	public MarkTool(int type) {
		this.type = type;
	}
	
	@Override
	public boolean mouseClicked(int x, int y, int modifiers) {
		EditController controller = EditController.instance();
		
		SimpleMark m = controller.getSimpleMark(x, y);
		if(m != null)
			controller.removeMark(m);
		
		if(m == null || m.getType() != type)
			controller.addMark(new SimpleMark(type, new Point(x, y)));
		
		return true;
	}
}
